/**
 * 
 */
package com.jcsi.facade_orm;

import java.sql.SQLException;

import com.jcsi.db.*;

/**
 * @author gahon_a
 *
 */
public class FacadeORM {

	DbManager		dbInstance = null;
	
	public FacadeORM(DbManager db) 
	{
		if (dbInstance == null)
			this.dbInstance = db;
	}
	
	public	String	getTableName(Object object)
	{
		String	TableName = object.getClass().getName();
		int	pos = (TableName.lastIndexOf('.') != 0) ? (TableName.lastIndexOf('.') + 1) : (0);
		TableName = TableName.substring(pos);
		System.out.println("Nom de la classe : "+TableName);
		return TableName;
	}
	
	public	void	Create(Object object)
	{
		String	TableName				=	this.getTableName(object);
		String	ColumnsList			=	new String();
		String	ColumnsValues		=	new String();
		
		System.out.println(TableName);
		try
		{
			dbInstance.resultSet = dbInstance.dbMetaData.getColumns(null, null, TableName, null);
			System.out.println(dbInstance.resultSetMetaData.getColumnCount());
			  while (dbInstance.resultSet != null && dbInstance.resultSet.next())
				  	System.out.println(dbInstance.resultSet.getString("COLUMN_NAME"));
		}
		catch (SQLException e)	{	e.printStackTrace();	}
	}
	
	public void		Read()
	{
		
	}
	
	
	public void		Update()
	{
		
	}
	
	public void		Delete()
	{
		
	}
	
}
